<template>
  <div>
    <div
      style="color: white;font-size: 22px;position: absolute;top: 115px;left: 67px;"
      @click="$router.push({path: '/Other'})"
    >
      <van-icon name="arrow-left" />
      <span style="position: absolute;width: 100px;top: -5px;left: 40px;">其他资讯</span>
    </div>
    <div align="center">
      <v-touch v-on:swipeleft="onSwipeLeft" v-on:swiperight="onSwipeRight" tag="div">
        <div class="left" @click="onSwipeRight">
          <van-icon name="arrow-left" />
        </div>
        <div class="right" @click="onSwipeLeft">
          <van-icon name="arrow" />
        </div>
        <div style="position: absolute;top: 165px;left: 180px;right: 180px;">
          <van-row gutter="40" class="a-fadeinL">
            <van-col span="8" v-for="(item,index) in list" :key="index">
              <img
                :src="item.informationUrl"
                style="box-shadow: 5px 15px 10px rgb(28,32,44);border-radius: 10px;width:267px;height:173px"
                @click="getImg(index)"
              />
              <span
                style="color: white;font-size: 20px;display: block;padding: 10px 0px;"
              >{{item.informationDescribe}}</span>
            </van-col>
          </van-row>
          <!-- <van-row gutter="40" class="a-fadeinR">
            <van-col span="8" v-for="(item,index) in list2" :key="index">
              <img
                :src="item.informationUrl"
                style="box-shadow: 5px 15px 10px rgb(28,32,44);border-radius: 10px;width:267px;height:173px"
                @click="getImg(0)"
              />
              <span
                style="color: white;font-size: 20px;display: block;padding: 10px 0px;"
              >{{item.informationDescribe}}</span>
            </van-col>
          </van-row>-->
        </div>
      </v-touch>
    </div>
  </div>
</template>

<script>
import { ImagePreview } from "vant";
let _this;
export default {
  name: "OtherInf",
  data() {
    return {
      current: 1,
      size: 6,
      list: [],
      list2: [],
      images:[],
      pages:''
    };
  },
  beforeCreate() {
    // 创建 vue 实例之前
    _this = this;
  },
  watch: {},
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      let params = {
        informatTypeID: this.$route.query.pageId,
        size: this.size, //每页条数
        current: this.current //页码
      };

      this.$http
        .get("/information/SelectInformationByID", { params: params })
        .then(res => {
          if (res.data.code == 200) {
            this.list = res.data.data.records;
            // this.list = this.list.splice(0, 2);
            // this.list2 = res.data.data.records;
            console.log('111');
             this.images = res.data.data.records.map(item => {
              return item.informationUrl;
            });
            // console.log(this.images);
            // this.list = this.list.splice(0, 3);
            // this.list2 = res.data.data.records;
            this.pages = res.data.data.pages;
          } else if (res.code == 500) {
            this.$notify(res.msg);
          }
        });
    },
    onSwipeLeft() {
      // 左滑
      if (this.current < this.pages) {
        this.current++;
        this.getList();
      }
    },
    onSwipeRight() {
      // 右滑
      if (this.current > 1) {
        this.current--;
        this.getList();
      }
    },
    getImg(index) {
      ImagePreview({
        // images: [
        //   require("../assets/e1.png"),
        //   require("../assets/e2.png"),
        //   require("../assets/e3.png"),
        //   require("../assets/e4.png"),
        //   require("../assets/e5.png"),
        //   require("../assets/e6.png")
        // ],
         images: this.images,
        startPosition: index
      });
    }
  }
};
</script>

<style lang="less" scoped>
/deep/ .van-icon {
  font: 24px/1 "vant-icon";
}

/deep/ .van-row {
  margin-right: 0 !important;
}

.left /deep/ .van-icon {
  font: 48px/1 "vant-icon";
  color: rgb(56, 107, 146);
}

.left {
  position: absolute;
  top: 230px;
  left: 100px;
}

.right /deep/ .van-icon {
  font: 48px/1 "vant-icon";
  color: rgb(53, 86, 114);
}

.right {
  position: absolute;
  top: 450px;
  left: 100px;
}
</style>